package com.nf.service;

import com.nf.entity.Student;
import com.nf.mapper.DaoMapper;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.beans.factory.annotation.Qualifier;
import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional;

@Service
public class TestServiceImpl2 implements TestService{
    @Autowired
    private Student student;

    //因为daoMapperImp实现类使用了@Repository注解了 自动配置了bean 所以可以@Autowired注解实例
    @Autowired
    private DaoMapper daoMapper;
    public TestServiceImpl2(){
        System.out.println("service实例创建了2"+this);
    }

    @Override
    public String kk() {
        daoMapper.getString();
        System.out.println(student.getName());
        return daoMapper.getString();
    }
//    ------------------------------------
    @Autowired
    @Qualifier("studentGirl")
    private Girl girl;

    @Override
    public String CC() {
        girl.play();
        girl.eat();
        return "";
    }

    @Transactional
    @Override
    public void 转账() {
        System.out.println("数据库操作");
        daoMapper.数据库操作();
    }
}
